#include <osa.h> 
#include <service/osa_bsem.h>


#define BUTTON_1 PORTBbits.RB0

void task_keyboard(void)
{
	char status, status_old;
	
	while(1){
		status = ( BUTTON_1 == 1);
		if (BUTTON_1 & !OS_CheckBSem(BS_BUTTON_1_REL)) {//pressed
			OS_RunSTimer (1, 2);//deve essere premuto per 100 ms
			OS_WaitSTimer(1);
			if  (BUTTON_1) {
				OS_RunSTimer (1, 1);
				OS_WaitSTimer(1);
				while (BUTTON_1) ;
					OS_SetBSem(BS_BUTTON_1_REL); //FIXME
			}
		}
		OS_Yield();
	}//while
}//task keyboard